<template>
  <el-dialog show-close width="50%"
             :visible.sync="dialogVisible"
             :before-close="handleClose"
             append-to-body>
    <avue-form ref="form" :option="option"
               v-model="formData" @submit="submitData"></avue-form>

  </el-dialog>
</template>

<script>
import {createShare} from "@/api/start/formEngine/shareApi";

export default {
  name: "createShare",
  computed: {
    option() {
      return {
        labelWidth: 180,
        column: [
          {
            label: '有效时长（天）',
            prop: 'effectiveTimeDay',
            span: 24,
            type: "radio",
            button: true,
            value: 1,
            dicData: [
              {label: "1天", value: 1},
              {label: "3天", value: 3},
              {label: "7天", value: 7},
              {label: "永久", value: -1},
            ],
            rules: [{
              required: true,
              message: "请选择有效时长",
              trigger: "blur"
            }]
          },
          {
            label: '提取码',
            span: 24,
            prop: 'pwd',
            maxlength: 6,
            minlength: 6,
            rules: [{
              required: false,
              message: "请输入提取码",
              trigger: "blur"
            }]
          },
        ]

      }
    }
  },
  data() {
    return {
      dialogVisible: false,
      formData: {},
      tableId: null,
    }
  },
  methods: {
    show(row) {
      this.dialogVisible = true;
      this.tableId = row.id;
    },
    submitData(form, done) {
      done();
      createShare(this.tableId, this.formData).then(res => {
        this.handleClose()
      })

    },
    handleClose() {
      this.dialogVisible = false;
      this.formData = {};
    }
  }
}
</script>

<style scoped>

</style>
